import request from '@/js/request'

const BASE_URL = '/model/form/config'

/**
 * 获取模型表单配置
 * @param modelId 模型Id
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getModelFormConfigs(modelId) {
  return request.get(BASE_URL, {params: {modelId}})
}

/**
 * 删除模型表单配置
 * @param ids
 * @returns {Promise<AxiosResponse<any>>}
 */
export function deleteFormConfig(ids) {
  return request.delete(BASE_URL, {params: {ids: ids.join(',')}})
}

/**
 * 保存。修改数据
 * @param data 需改后的数据
 * @param edit true：修改，false：新建
 * @returns {Promise<AxiosResponse<any>>}
 */
export function saveAndEdit(data, edit) {
  if (edit){
    return request.put(BASE_URL, data)
  }
  return request.post(BASE_URL, data)
}
